﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Text;
using System.IO;
using System.Dynamic;
using FluorineFx.Json;

namespace lxwmvc
{
    /// <summary>
    /// 信息查询接口
    /// </summary>
    public static partial class huifucontroller
    {
        /*
="1" >未审批
2" >未上线
3" >领投中
4" >投资中
5" >募资成功
6" >流标
7" >逾期
8" >转债权
9" >未通过
10" >还款中
11" >即将发布
12" >预览
13" >已完成
14" >转让完毕
        */

        /// <summary>

        /// </summary>
        /// <param name="pb"></param>
        //public static void huifu_chongzhi(pagebase pb)
        //{
            
        //}
        /// <summary>
        /// 输出最大编号
        /// </summary>
        /// <param name="pb"></param>
        [json]
        public static void huifu_getmaxid(pagebase pb)
        {
            var leixing = pb.v_ss("leixing");
            var maxid = queryhelper.get(" execute  lxwGSN '" + leixing + "','','1','000001' ");

            pb.write(maxid+"");

            //RenderText(maxid);
            //this.CancelLayout();
            //this.CancelView();
        }
        
        /// <summary>
        /// 查询用户的账户余额
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="zongyue"></param>
        /// <param name="dongjieyue"></param>
        /// <param name="shifoushanghu">true 代表是查询商户的余额</param>
        /// <returns></returns>
        public static string huifu_chaxun_yue(string uid, out string zongyue, out string dongjieyue, bool shifoushanghu)
        {
            
            //账户余额
            string yue = "0.00";
            //账户总额
            zongyue = "0.00";
            //账户冻结
            dongjieyue = "0.00";
            try
            {
                QueryBalanceBg sendobj = new QueryBalanceBg();
                if (!shifoushanghu)
                    sendobj.UsrCustId = core_user.getUsrCustId(uid);
                else
                    sendobj.UsrCustId = HuiFuArg.MerCustId + "";

                var tobjrev = core_huifu.Send<RetQueryBalanceBg>(sendobj);
                {
                    if (tobjrev != null && tobjrev.RespCode == core_huifu.HUIFU_SUCCESS)
                    {
                        //账户总额
                        zongyue = tobjrev.AcctBal.ToString();
                        //账户冻结
                        dongjieyue = tobjrev.FrzBal.ToString();
                        //可用余额
                        yue = tobjrev.AvlBal.ToString();
                    }
                }
            }
            catch(Exception err)
            {
                dataloger.fatal("huifu_chaxun_yue", err);
                //账户余额
                yue = "汇付维护中";
                //账户总额
                zongyue = "汇付维护中";
                //账户冻结
                dongjieyue = "汇付维护中";
            }
            return yue;
        }

        //查询方法基本上都是同步方法
        //放款交易查询对账
        //public void fangkuanduizhang(string PageNum, string PageSize, string begintime, string endtime, string QueryTransType)
        //{
        //    Reconciliation objsend = new Reconciliation();
        //    objsend.MerCustId = ConfigurationManager.AppSettings["MerCustId"].tostr();
        //    objsend.BeginDate = begintime;
        //    objsend.EndDate = endtime;
        //    objsend.PageNum = PageNum;
        //    objsend.PageSize = PageSize;
        //    objsend.QueryTransType = QueryTransType;
        //    WebPost.Submit(objsend);
        //}

        ////商户扣款对账
        //public void koukuanduizhang(string PageNum, string PageSize, string begintime, string endtime)
        //{
        //    TrfReconciliation objsend = new TrfReconciliation();
        //    objsend.MerCustId = ConfigurationManager.AppSettings["MerCustId"].tostr();
        //    objsend.BeginDate = begintime;
        //    objsend.EndDate = endtime;
        //    objsend.PageNum = PageNum;
        //    objsend.PageSize = PageSize;
        //    WebPost.Submit(objsend);
        //}

        ////自动投标计划状态查询
        //public void toubiaoduizhang(string usrcustid)
        //{
        //    QueryTenderPlan objsend = new QueryTenderPlan();
        //    objsend.MerCustId = ConfigurationManager.AppSettings["MerCustId"].tostr();
        //    objsend.UsrCustId = usrcustid;
        //    WebPost.Submit(objsend);
        //}
    }
}